import { Injectable } from '@angular/core';
import { HttpService } from '../../../core/http.service';
import { SERVERS_NAME } from '../../../config/config';
import { Observable } from 'rxjs/index';

@Injectable()
export class ClassManageService {

  protected preUrl = `${SERVERS_NAME.SECURITY_SERVER}sys/classes/`;

  constructor(private http: HttpService) {
  }

  /**
   * 查询列表
   */
  getClassList(data): Observable<any> {
    return this.http.post(data, `${this.preUrl}page`);
  }


  /**
   * 新增班级
   */
  submit(data) {
    return this.http.post(data, `${this.preUrl}create`);
  }

  /**
   * 获取学院
   */
  getCollegeList(data) {
    return this.http.get(data, `${SERVERS_NAME.SECURITY_SERVER}sys/dept/list`);
  }

  /**
   * 获取专业
   */
  getMajorList(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/college/listMajor`);
  }

  /**
   * 获取教师
   */
  getTeachList() {
    return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}sys/teacher/list`);
  }

  /**
   * 更新
   */
  update(data) {
    return this.http.post(data, `${this.preUrl}update`);
  }

  /**
   * 删除
   */
  delete(data) {
    return this.http.post(data, `${this.preUrl}delete`);
  }

  /**
   * 删除所有
   */
  deleteAll(data) {
    return this.http.post(data, `${this.preUrl}deleteAll`);
  }


  /**
   * @author leihfei
   * @date 2019-06-01
   * @description 文件导入
   */
  importExcel(formData: FormData): Observable<any> {
    return this.http.postFile(formData, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/classes/classesImport');
  }

  /**
   * 获取校区字典
   */
  getCampusDic(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/dictionary/page`);
  }
}
